//
//  Paging.h
//  SimulacraDB
//
//  Created by Andre Cohen on 8/10/08.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import "DataStream.h"
#import "Record.h"

@interface Paging : NSObject {
	NSString *name;
	DataStream *pages;
	DataStream *data;
	int blocksPerPage;
	int blockSize;
}

@property(readonly) NSString *name;
@property(readonly) int blocksPerPage;
@property(readonly) int blockSize;

- (id)initForData:(NSString *)filename 
		   blocks:(int)block;
- (void)close;

/** Insert/Get/Remove Record **/
- (void)writeRecord:(Record *)record;
- (Record *)getRecordAt:(Record *)record;
- (void)removeRecord:(Record *)record;

/** Raw read/write record from/to file **/
- (void)writeRecordData:(Record *)record;
- (Record *)readRecordData:(Record *)record;

- (int)pageCount;

- (ByteArray *)getPageNumber:(int)page;
- (void)savePage:(ByteArray *)page number:(int)num;
- (bool)getBlockAtPage:(int)page offset:(int)off;

@end
